<?php
    require_once('paths.inc');
    require_once('page.inc');
    require_once(INCLUDE_PATH . 'constants.inc');
    require_once('utils.inc');
    session_start();
    select_language();
    
	function show_interface () {
		
		if (isset($_GET['index'])) $index = $_GET['index'];
			
		if (isset($index)) {			
			checkIsLoggedIn();

			$contact = $_SESSION['firma']->contacte[$index];
	
			$text = LANG_CONTACT_UPDATE;
			$opt = "update";	
		}
		else {
			$text = LANG_CONTACT_CONFIRM;
			$opt = "insert";
			$contact = new Contact(null, null, null, null, null, null, null, null);
		}
		
		if (!isset($index)) $index = 0;
        
        $help_text = LANG_EXTRA_MODAL_ADD_CONTACT_FIRMA;
        if ($opt == "update")
            $help_text = LANG_EXTRA_MODAL_EDIT_CONTACT_FIRMA;
		
		$ret = '<div align=\"center\">				
					<table id="wrapper2" name="new_contact" border="0" align="center" cellpadding=\"3\" cellspacing=\"3\">
						<thead>
							<tr>
								<th colspan="2" align="center"> ' . $text . '</th>
							</tr>
						</thead>
						<tr class="capTabel">
							<td id="td_contact_nume" align="right"><b>' . LANG_NUME_CONTACT . CT_OBLIGATORIU . '</b></td>
							<td align="left"><input type="text" name="contact_nume" id="contact_nume" value="' . $contact->nume . '" size="' . CT_MODAL_ADD_CONTACT_INPUT_SIZE_TEXT_BOX . '" />
						</tr>
						<tr class="capTabel">
							<td id="td_contact_sex" align="right"><b>' . LANG_SEX_CONTACT . '</b></td>
							<td align="left">' . render_sex_select("contact_sex", "contact_sex", $contact->sex) . '</td>
						</tr>
						<tr class="capTabel">
							<td id="td_contact_functie" align="right"><b>' . LANG_FUNCTIE_CONTACT . '</b></td>
							<td align="left"><input type="text" name="contact_functie" id="contact_functie" value="' . $contact->functie . '" size="' . CT_MODAL_ADD_CONTACT_INPUT_SIZE_TEXT_BOX . '" />
						</tr>		
						<tr class="capTabel">
							<td id="td_contact_tel_fix" align="right"><b>' . LANG_TEL_FIX_CONTACT . '</b></td>
							<td align="left"><input type="text" name="contact_tel_fix" id="contact_tel_fix" value="' . $contact->tel_fix . '" size="' . CT_MODAL_ADD_CONTACT_INPUT_SIZE_TEXT_BOX . '" />
						</tr>			
						<tr class="capTabel">
							<td id="td_contact_tel_fax" align="right"><b>' . LANG_TEL_FAX_CONTACT . '</b></td>
							<td align="left"><input type="text" name="contact_tel_fax" id="contact_tel_fax" value="' . $contact->tel_fax . '" size="' . CT_MODAL_ADD_CONTACT_INPUT_SIZE_TEXT_BOX . '" />
						</tr>			
						<tr class="capTabel">
							<td id="td_contact_tel_mobil" align="right"><b>' . LANG_TEL_MOBIL_CONTACT . '</b></td>
							<td align="left"><input type="text" name="contact_tel_mobil" id="contact_tel_mobil" value="' . $contact->tel_mobil . '" size="' . CT_MODAL_ADD_CONTACT_INPUT_SIZE_TEXT_BOX . '" />
						</tr>			
						<tr class="capTabel">
							<td id="td_contact_email" align="right"><b>' . LANG_EMAIL_CONTACT /*. CT_OBLIGATORIU */ . '</b></td>
							<td align="left"><input type="text" name="contact_email" id="contact_email" value="' . $contact->email . '" size="' . CT_MODAL_ADD_CONTACT_INPUT_SIZE_TEXT_BOX . '" />
						</tr>
						<tr class="capTabel">
							<td colspan="2" align="center">';
				                $ret .='<input type="button" name="contact_confirm" id="contact_confirm" value="' . $text . '"' . "onclick=\"javascript: new_contact_confirm('" . $opt ."'," . $index . ");\" />&nbsp;&nbsp;";
				                $ret .='<input type="button" name="contact_cancel" id="contact_cancel" value="' . LANG_CANCEL . '" onclick="javascript: closeMessage();" />
							</td>
						</tr>'
                        . output_extra_text_modal($help_text, 2) . 
					'</table>
			</div>
			<script type="text/javascript">
				document.contact_nume.focus();
			</script>';
			echo $ret;		
			flush();
	}
	
	show_interface();			
?>